#1 Create Nacos service discovery provider#2
Conversation
|
🆗 Great! Thank you for creation this PR! |
raman-m
left a comment
There was a problem hiding this comment.
Please organize the folder structure more efficiently.
There is no need to create sub-sub folders.
Ocelot.Discovery.Nacos/src/Ocelot.Discovery.Nacos/GlobalUsings.cs
Outdated
Show resolved
Hide resolved
Ocelot.Discovery.Nacos/test/Ocelot.Discovery.Nacos.UnitTest/MSTestSettings.cs
Outdated
Show resolved
Hide resolved
|
The solution and folder structure now appear satisfactory to me. |
There was a problem hiding this comment.
I've added GitHub Actions workflows. And the latest build job produced a number of warnings (see in Files changed).
Could you fix all of them please?
src/Nacos.cs
Outdated
|
|
||
| return new Service( | ||
| id: instance.InstanceId, | ||
| hostAndPort: new ServiceHostAndPort(instance.Ip, instance.Port), |
There was a problem hiding this comment.
| hostAndPort: new ServiceHostAndPort(instance.Ip, instance.Port), | |
| hostAndPort: new(instance.Ip, instance.Port), |
What is the scheme? Is the scheme known at this stage of building service?
There was a problem hiding this comment.
When a client fetches a service, it will access the corresponding service based on the address information at the time of registration, so if the registration is for an HTTPS address, then the fetched service is HTTPS, and vice versa.
There was a problem hiding this comment.
So, in the Nacos service discovery, scheme (protocol) management is not required, right?
For example, in Kubernetes we can manage the protocol while registering a service instance in the K8s registry.
In the next round of development, we will write acceptance tests that will show real usage in practice.
raman-m
left a comment
There was a problem hiding this comment.
Please fix warnings generated by static code analysis tool during execution of latest GitHub action build.
|
Miao, what is the current code coverage achieved by unit tests? |
|
61% coverage is low. |
4b53651 to
d7c7c33
Compare
There was a problem hiding this comment.
Thank you for addressing the issues from the previous code review! ❤️
The repository looks much better now with the initial solution and unit testing in place. However, I am concerned that it has not been tested with real HTTP requests. It would be prudent commence acceptance testing at this stage. We need to conduct load testing to ensure that the provider can handle a high number of parallel requests.
- I'm going to add a commit with a draft version of the acceptance testing project.
- Please find below my additional suggestions for improving the code.
| id: instance.InstanceId, | ||
| hostAndPort: new(instance.Ip, instance.Port), | ||
| name: instance.ServiceName, | ||
| version: metadata.GetValueOrDefault("version", "default"), |
There was a problem hiding this comment.
I cannot get this default value. Could you show me in Nacos docs please that default version is marked as "default"?
There was a problem hiding this comment.
The version value is not explicitly defined as "default" in the Nacos documentation. The "default" value in the code is a custom fallback in case there is no "version" key in the metadata dictionary.
There was a problem hiding this comment.
You confirmed that this is the issue. I am not certain but these values may be applicable: current, latest, default.
Question: How can the default be consumed by Ocelot or Nacos client?
There was a problem hiding this comment.
The version can be customized through the configuration file.
src/Nacos.cs
Outdated
| private static string FormatTag(KeyValuePair<string, string> kv) | ||
| => $"{WebUtility.UrlEncode(kv.Key)}={WebUtility.UrlEncode(kv.Value)}"; | ||
|
|
||
| private static readonly string[] _reservedKeys = { "version", "group", "cluster", "namespace", "weight" }; |
There was a problem hiding this comment.
It might be better to make this definition public.
Could you provide some links to metadata documentation that explain this?
I suggest writing an XML documentation (in the code) for the definition of the array.
There was a problem hiding this comment.
In the nacos java version of the sdk, these are included by default, but in the nacos .net sdk these are not included by default and need to be added by yourself.
There was a problem hiding this comment.
Please make this array publicly accessible, then.
| builder.Services | ||
| .AddNacosAspNet(builder.Configuration,section) | ||
| .AddSingleton(NacosProviderFactory.Get) | ||
| .AddSingleton(NacosMiddlewareConfigurationProvider.Get); |
There was a problem hiding this comment.
Just a word of caution!
It might be premature to define this since you were inspired by the Consul provider and ConsulMiddlewareConfigurationProvider implementation. However, please note that this Consul config provider was developed specifically for the AddConfigStoredInConsul() feature, correct?
Therefore, let's keep it in the code for now, the next phase of acceptance testing will reveal the subsequent steps.
|
Hello, Miao! Current pitfalls of the project:
Finally, I believe that releasing this package for .NET 6+8 with the draft acceptance testing project is acceptable. However, we must develop real tests, and they must pass. Let's go! |
|
@MiaoShuYo commented on March 21
🆗 I am curious to know which IDE and code coverage did you utilize for measurement? |
Rider |
|
Please work on the acceptance tests as they are a required part of the PR process. Afterward, I will assist you in writing documentation. Do not hesitate to ask questions, I understand that acceptance testing can be a challenging milestone. P.S. Currently I am occupied with the release of the Ocelot version for .NET9. Apologies for being very busy at moment. |
|
I am very sorry that I recently had an operation due to an accident, so I cannot carry out relevant development for the time being. It is expected to be suspended for three to five months. |
|
Wow, I'm saddened to hear that! I wish you a smooth and speedy recovery. 💟 P.S. Since development will be suspended for the next X months, I need to inform you that the package will not be released. The version for .NET 9 will be released after your return to development. In the meantime, within the next 1–2 months, I’ll try to release a very draft version for the current TFMs: |
|
@MiaoShuYo Hello, Miao! FYI, I will review the pull request and merge it as-is because I need some actual code for CI-CD. |
raman-m
left a comment
There was a problem hiding this comment.
After updating the packages, I realized that updating the target framework monikers is impossible. So, TFMs remain net6.0 and net8.0 because the integrated nacos-sdk-csharp package explicitly targets these TFMs.
Ready for merging but not for delivery
Please note ❕ Following the merging of this PR we will proceed with following actions →
- Configure CI-CD (GitHub Actions) for package delivery (assigned to @raman-m).
- Develop acceptance tests, which are currently absent and are draft (assigned to @MiaoShuYo and @raman-m).


Closes #1
Related to